package model.dao;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import model.util.HibernateUtil;
import model.pojo.*;


/**
 *
 * @author CUCAINHO
 */
public class DanhMucDao {
    
    public static List<Danhmuc> LayDanhSachDanhMuc() { 
            
    List<Danhmuc> danhSachDanhMuc = null;
    
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
            String hql = "select dm from Danhmuc dm"; 
            Query query = session.createQuery(hql);
            //Query query = session.createQuery(hql);             
            danhSachDanhMuc = query.list(); 
        }catch (HibernateException ex) 
        { //Log the exception 
            System.err.println(ex); 
        } 
        finally {
            session.close(); 
        } 
    return danhSachDanhMuc; 
    }
}
